import { Api } from 'pf-component';
import { BaseApi, ServiceEnum } from '@/constants/api/base-api';
import { MethodTypeEnum } from '@/constants/enum/method-type.enum';

class DataApi {
  classApi: Api = {};
  classPeriodApi: Api = {};
  classroomApi: Api = {};
  studentApi: Api = {};
  courseApi: Api = {};

  constructor() {
    this.initKm();
  }

  initKm() {
    this.classApi = {
      list: {
        url: this.getUrl() + '/dcClass/list',
        method: MethodTypeEnum.GET
      },
      addOrUpd: {
        url: this.getUrl() + '/dcClass/addOrUpd',
        method: MethodTypeEnum.POST
      }
    };
    this.classroomApi = {
      list: {
        url: this.getUrl() + '/dcClassroom/list',
        method: MethodTypeEnum.GET
      },
      addOrUpd: {
        url: this.getUrl() + '/dcClassroom/addOrUpd',
        method: MethodTypeEnum.POST
      }
    };
    this.classPeriodApi = {
      list: {
        url: this.getUrl() + '/dcClassPeriod/list',
        method: MethodTypeEnum.GET
      },
      addOrUpd: {
        url: this.getUrl() + '/dcClassPeriod/addOrUpd',
        method: MethodTypeEnum.POST
      }
    };
    this.studentApi = {
      list: {
        url: this.getUrl() + '/dcStudent/list',
        method: MethodTypeEnum.GET
      },
      addOrUpd: {
        url: this.getUrl() + '/dcStudent/addOrUpd',
        method: MethodTypeEnum.POST
      },
      moveClass: {
        url: this.getUrl() + '/dcStudent/moveClass',
        method: MethodTypeEnum.POST
      }
    };
    this.courseApi = {
      list: {
        url: this.getUrl() + '/dcCourse/list',
        method: MethodTypeEnum.POST
      },
      addOrUpd: {
        url: this.getUrl() + '/dcCourse/addOrUpd',
        method: MethodTypeEnum.POST
      },
      preview: {
        url: this.getUrl() + '/dcCourse/preview',
        method: MethodTypeEnum.GET
      }
    };
  }
  getUrl(): string {
    return BaseApi.getUrl(ServiceEnum.system);
  }
}
export const dataApi = new DataApi();
